﻿<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" Codebehind="addopenproject.aspx.cs"
    Inherits="LabMS.Web.OpenProject.addopenproject" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>实验开放项目申请表</title>
    <link type="text/css" rel="stylesheet" href="../style/screen.css" />
    <link href="../css/jquery.wysiwyg.css" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../style/ie7.css" />
    <![endif]-->
</head>
<body class="mainBody">
    <form id="form1" runat="server" enctype="multipart/form-data">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        <a href="currentopenprojectlist.aspx">本学期开放项目列表</a></label>&gt;添加实验开放项目申请
                </div>
            </div>
        </div>
        <div class="main">
            <p>
                <asp:Button ID="bnSave" CssClass="button" runat="server" Text="保存" OnClick="bnSave_Click" />
                <asp:Button ID="btnApp" CssClass="button" runat="server" Text="申请" OnClick="bnSave_Click" />
                <input id="btnReturn" class="button" type="button" onclick="javascript:window.location.href='currentopenprojectlist.aspx'"
                    value="返回" />
            </p>
            <table border="0" cellpadding="4" cellspacing="0">
                <tr>
                    <td>
                        <label class="itemTitle">
                            申请人:
                        </label>
                    </td>
                    <td>
                        <asp:Label ID="lbAppPerson" runat="server" Text=""></asp:Label>
                    </td>
                    <td>
                        <label class="itemTitle">
                            申请时间:
                        </label>
                    </td>
                    <td>
                        <asp:Label ID="lbAppDate" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验名称:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbProjectName" runat="server" MaxLength="25"></asp:TextBox>
                    </td>
                    <td>
                        <label class="itemTitle">
                            实验编号:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbProjectCode" runat="server" MaxLength="25"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验室:</label><span style="color: #ff0000">*</span></td>
                    <td>
                        <asp:DropDownList ID="ddlLabName" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <label class="itemTitle">
                            实验类别:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProjectCategory" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验类型:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProjectType" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <label class="itemTitle">
                            实验所属学科</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <input id="tbProjectSubjectName" readonly="readonly" runat="server" type="text" />
                        <input id="tbProjectSubjectCode" style="display: none" runat="server" type="text" />
                        <input id="btProjectSubjectselect" name="btProjectSubjectselect" onclick="OpenEditWin('../Equipment/Dictionary.aspx?Type=xueke',500,400,'tbProjectSubjectCode','tbProjectSubjectName')"
                            type="button" value="..." class="button" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验要求:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProjectRequire" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <label class="itemTitle">
                            实验者类别:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProjectPartnerType" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            面向专业:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPProfessioanl" runat="server" MaxLength="15"></asp:TextBox>
                    </td>
                    <td>
                        <label class="itemTitle">
                            面向年级:</label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlOPGrade" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="itemTitle">
                            计划学时:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPPlanningCourseTime" runat="server" MaxLength="2"></asp:TextBox>
                    </td>
                    <td>
                        <label class="itemTitle">
                            专项经费:</label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlOPFunds" runat="server">
                            <asp:ListItem Text="无" Value="0"></asp:ListItem>
                            <asp:ListItem Text="有" Value="1"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验项目来源:</label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProjectComFrom" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>
                        <label class="itemTitle">
                            项目负责人:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPInCharge" runat="server" MaxLength="5"></asp:TextBox>
                    </td>
                    <td>
                        <label class="itemTitle">
                            联系电话:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPPhone" runat="server" MaxLength="10"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td valign="top">
                        <label class="itemTitle">
                            实验内容:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPContent" MaxLength="150" TextMode="MultiLine" runat="server"
                            Height="100px" Width="340px"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>
                        <label class="itemTitle">
                            实验周次:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <asp:TextBox ID="tbProjectStartWeek" runat="server" MaxLength="2" Width="70px"></asp:TextBox>
                        --
                        <asp:TextBox ID="tbProjectEndWeek" runat="server" MaxLength="2" Width="70px"></asp:TextBox>
                    </td>
                    <td>
                        <label class="itemTitle">
                            指导老师:</label><span style="color: #ff0000">*</span>
                    </td>
                    <td>
                        <input id="tbTeacherName" readonly="readonly" style="width: 78px" runat="server"
                            type="text" />
                        <input id="tbTeacherCode" style="display: none" runat="server" type="text" />
                        <% if (UserType == "mana")
                             {%>
                        <input id="Button1" name="btProjectSubjectselect" onclick="OpenEditWin('../CommonPage/TeacherList.aspx?Type=course',500,400,'tbTeacherCode','tbTeacherName')"
                            type="button" value="..." class="button" />
                            <%} %>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td valign="top">
                        <label class="itemTitle">
                            实验学生:</label>
                    </td>
                    <td>
                        <input id="btnAddStudent" class="button" name="btProjectSubjectselect" onclick="OpenEditWin2('../CommonPage/studentslist.aspx',800,400)"
                            type="button" value="添加" />
                        <div id="studentlist" runat="server" style="margin-top: 5px;">
                        </div>
                        <input id="tblistEmpty" style="display: none" value="1" runat="server" type="text" />
                        <input id="tblistStudents" style="display: none" value="" runat="server" type="text" />
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>
                        <label class="itemTitle">
                            申请说明:</label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbOPReason" MaxLength="150" TextMode="MultiLine" runat="server"
                            Height="100px" Width="340px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                      <label class="itemTitle"> 附件上传：</label> 
                    </td>
                    <td>
                        <input type="file" id="attachment"  />
                    </td>
                </tr>
            </table>
        </div>
        <input id="tb_StudentIDs" style="display: none" runat="server" type="text" />

        <script type="text/javascript" src="../js/Common.js"></script>

        <script type="text/javascript" src="../js/jQuery/jquery-1.3.1.js"></script>

        <script type="text/javascript" src="../js/jQuery/jquery.json-1.3.min.js"></script>

        <script type="text/javascript" src="../js/jQuery/jquery.validate.js"></script>

        <script type="text/javascript" src="../js/jQuery/jquery.MultiFile.js" language="javascript"></script>

        <script type="text/javascript">
      function OpenEditWin(frmWin,width,height, obj1, obj2) 
      {
           var me; 
           me = window;
           var ret = window.showModalDialog(frmWin,me,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no');
              if (ret != null) 
            {
                document.getElementById(obj1).value = ret[0];
                document.getElementById(obj2).value = ret[1];
            }
      }
     
      
    $(document).ready(function(){
        $("#form1").validate({
            rules: {
                tbProjectName: "required",
                tbProjectCode: "required",
	            tbProjectSubjectName: "required",
	            tbProjectStartWeek:{number:true,required:true},
	            tbProjectEndWeek:{number:true,required:true},
	            tbTeacherName:"required"
            },
            messages: {
                tbProjectName:"请输入实验名称",
                tbProjectCode:"请输入实验代码",
                tbProjectSubjectName:"请输入实验所属学科",
                tbProjectStartWeek: {
		            number:"请输入数字",
		            required:"请填写开始周次"
                },
                tbProjectEndWeek: {
		            number:"请输入数字",
		            required:"请填写结束周次"
                },
                tbTeacherName:"请输入指导老师"
            }
            
          
            
        });
        
        
        
          $('#attachment').MultiFile({ 
              accept:'doc|docx|txt|pdf',max:6, 
              STRING: { 
                  remove:'删除', 
                  selected:'Selecionado: $file', 
                  denied:'不支持的文件类型 $ext!', 
                  duplicate:'文件重复 :\n$file!' 
                      } 
             });
            

        if($("#tblistStudents").val() !="" )
            $("#studentlist").html($("#tblistStudents").val());

        $("#studentlist  a").css("cursor","pointer"); 

        $("#studentlist  a").click( function (){
            var strsID = $(this).parent().parent().children().html();
            var listID = $("#tb_StudentIDs").val().split(',');
            var value = "";
            for(var i=0; i<listID.length; ++i) {
                if(listID[i] != strsID) {
                    if(value=="") {
                        value = listID[i];
                    } else {
                        value += "," + listID[i];
                    }
                 }
            }

            $("#tb_StudentIDs").val(value);
            $(this).parent().parent().remove();

            if($("#tb_StudentIDs").val()=="") {
                $("#studentlist").html("");
                $("#tblistEmpty").val(1); 
            }

            $("#tblistStudents").val($("#studentlist").html());
        });
    });

     function OpenEditWin2(frmWin,width,height) 
      {
           var me; 
           me = window;  
           var ret = window.showModalDialog (frmWin, me, 'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no');
            
          if (ret != null) 
           { 
                var strTable = ""; 
                var listEmpty = $("#tblistEmpty").val();
                if(listEmpty=="1")
                {  
                    var HTML = "<table id='studenlist' class='infoTable' border='1' style='width: 300px; border-collapse: collapse;'>";
                    HTML += "<thead>";
                    HTML += "<tr class='header'>";
                    HTML += "<td class='none'>";
                    HTML += "ID";
                    HTML += "</td>";

                    HTML += "<td>";
                    HTML += "学号";
                    HTML += "</td>";

                    HTML += "<td>";
                    HTML += "姓名";
                    HTML += "</td>";
                    HTML += "<td>";
                    HTML += "";
                    HTML += "</td>"; 
                    HTML += "</tr>";
                    HTML += "</thead>"; 
                    strTable +=   HTML;
                   $("#tblistEmpty").val(0); 
                }
                
                var HTML2 = ""; 
                var value=$("#tb_StudentIDs").val();
                var listID = value.split(',');
                 for(var j=0; j<ret.Items.length; ++j)
                {
                    var item = ret.Items[j];
                   if(value!=""){
                        var HasID = false;
                        for(var i=0; i<listID.length; ++i)
                        {
                            if(listID[i] == item.ID)
                           {
                            HasID = true; 
                            }  
                        } 
                        if(!HasID)
                        { 
                            HTML2 += "<tr>"; 
                            HTML2 += "<td class='none'>"; 
                            value=value+","+item.ID; 
                            $("#tb_StudentIDs").val(value);  
                            HTML2 += item.ID; 
                            HTML2 += "</td>"; 
                            HTML2 += "<td>"; 
                            HTML2 += item.Code; 
                            HTML2 += "</td>";
                            HTML2 += "<td>"; 
                            HTML2 += item.Name; 
                            HTML2 += "</td>";
                           HTML2 += "<td>"; 
                            HTML2 += "<a>删除</a>"; 
                            HTML2 += "</td>"; 
                            HTML2 += "</tr>";  
                            strTable +=   HTML2; 
                           HTML2 = ""; 
                        }   
                    }else
                    {
                        HTML2 += "<tr>"; 
                        HTML2 += "<td class='none'>"; 
                        value=item.ID;
                        HTML2 += item.ID; 
                        HTML2 += "</td>"; 
                        HTML2 += "<td>"; 
                        HTML2 += item.Code; 
                        HTML2 += "</td>";
                        HTML2 += "<td>"; 
                        HTML2 += item.Name; 
                        HTML2 += "</td>";
                        HTML2 += "<td>"; 
                        HTML2 += "<a>删除</a>"; 
                        HTML2 += "</td>";
                        HTML2 += "</tr>";  
                        strTable +=   HTML2; 
                        HTML2 = ""; 
                    }       
                }
                $("#tb_StudentIDs").val(value); 
                 
                if(listEmpty=="1")
                {  
                    var HTML3 = "</table>";
                    strTable +=   HTML3;    
                    $("#studentlist").append(strTable); 
                }
                else
                {
                    $("#studentlist").children().children("tbody").append(strTable);
                }
                $("#tblistStudents").val($("#studentlist").html());
                
               $("#studentlist  a").css("cursor","pointer"); 
              
               
              $("#studentlist  a").click( function () 
                                                     { 
                                                        var strsID = $(this).parent().parent().children().html();
                                                        var listID = $("#tb_StudentIDs").val().split(',');
                                                        var value = "";
                                                          for(var i=0; i<listID.length; ++i)
                                                         {
                                                             if(listID[i] != strsID)
                                                            {
                                                                  if(value=="")
                                                                 {
                                                                    value = listID[i];
                                                                 } 
                                                                 else
                                                                {
                                                                    value += "," + listID[i];
                                                                }  
                                                             }
                                                               
                                                         } 
                                                        $("#tb_StudentIDs").val(value); 
                                                        $(this).parent().parent().remove();
                                                        if($("#tb_StudentIDs").val()=="")
                                                        {
                                                            $("#studentlist").html("");
                                                            $("#tblistEmpty").val(1); 
                                                        }
                                                           $("#tblistStudents").val($("#studentlist").html()); 
                                                 }); 
              
           }  
      } 
        </script>

        <asp:Label ID="lbErr" runat="server" ForeColor="Red" Text="Err" Visible="False"></asp:Label>
    </form>
</body>
</html>
